<?php
/**
 * Created by PhpStorm.
 * User: lwt
 * Date: 4/24/19
 * Time: 4:46 PM
 */

namespace app\admin\model;

use think\Db;
use think\Model;

class TraceSourceModel extends Model
{
    public static function addTraceSource($data){
        $msg = Db::table('tb_admin_trace_source')->insert($data);
        return $msg;
    }

    public static function updateTraceSourceById($data){
        $msg = Db::table('tb_admin_trace_source')->where('tas_id', $data["tas_id"])->update($data);
        return $msg;
    }

    public static function deleteTraceSourceById($tas_id){
        $msg = Db::table("tb_admin_trace_source")->where("tas_id",$tas_id)->find();
        $isNull = true;
        if (is_array($msg)){
            $isNull = false;
        }
        if ($isNull){
            return 0;
        }else{
            $msg = Db::table('tb_admin_trace_source')->delete($tas_id);
            return $msg;
        }
    }

    public static function selectAllTraceSourceById($co_id){
        $msg = Db::query('select *  from tb_admin_trace_source where co_id = ? order by tas_time asc',[$co_id]);
        return $msg;
    }
}